home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-22 | 2.8 KB | 125 lines | [TEXT/R*ch] |
- Notes
- {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business. remove viewFont for current Styles default
- //ERASE! in order to erase existing entries in this folder first
-
- graphic0.nwt -- Slurpee format
- 1/1/95
- Copyright 1994, 1995 S. Weyer. All Rights Reserved Worldwide.
- To be distributed only with Newt 2.5 package
-
- introductory Newt graphics examples
-
- sources for: poly, poly2, polyspi, squiral, cCurve, house, rect
-
- see graphic1.nwt for: squiral2 (interruptible version), dCurve,
- fractal, hilbert, fourNewts (multiple Newts), tree
-
- see NewtTurT -- interactive tutorial for more description
-
- To minimize text entry, use the Slurpee utility and a terminal emulator to
- transfer this text file as paragraphs in the Notepad. The folder in 2nd line
- is currently set on nil (Unfiled); select same folder in Newt to load.
-
- ----------
- poly2
- //:poly2 (5,80,360/5,0)
- //:poly2 (5,80,180-180/5,0)
- //:poly2 (times,dist,deg,90)
- func(nsides,len,ang,ang2)
- // poly with an extra turn at end for squiral & squiral2
- // also, ang precomputed & passed
- // assumes nsides already checked
- begin
- local i;
- for i:=1 to nsides
- do begin
- :go(len); :turn(ang);
- end;
- :turn(ang2);
- end
- ----------
- poly
- //:poly (4,100)
- //:poly (times,dist)
- //local i; for i:=3 to times do :poly(i,dist)
- //:poly(Random(3,15),Random(10,20))
- func (nsides,len)
- if nsides>0
- then :poly2(nsides, len, 360/nsides, 0)
- else :beep()
- ----------
- squiral
- //:squiral (10,75)
- //:squiral (times,dist)
- //:addNewt('[[newt1,-55,75,1],[newt2,55,75,2],[newt3,55,-75,1],[newt4,-55,-75,2]],nil,nil,nil)
- //newt1:poly2(5,40,144,0)
- //:squiral (8,40)
- //:cCurve (6,4,0)
- func (num,len)
- // draw <num> squares
- // each of size <len>
- // after each, turn 360/num
- if num>0
- then begin
- local i, ang2:=360/num;
- for i:=1 to num
- do :poly2 (4,len,90,ang2);
- end
- else :beep()
- ----------
- cCurve
- //:cCurve (6,8,0)
- //:cCurve (8,4,0)
- //:cCurve (times,dist,deg)
- func(num,dist,deg)
- if num>0 // warning num>8 could take awhile...
- then begin // the double-recursion (not a simple "tail recursion")
- :cCurve(num-1, dist, deg+45);
- :cCurve(num-1, dist, deg-45);
- end
- else begin // where the actual drawing occurs
- :turnTo(deg);
- :go(dist);
- end
- ----------
- polyspi
- //:polyspi (100,10,89)
- //:polyspi (times,dist,deg)
- func(num,size,angle)
- begin
- local i;
- for i:=1 to num
- do begin
- :go(size); :turn(angle);
- size:=size+1;
- end;
- end
- ----------
- house
- //:house (dist)
- func(size)
- begin
- local dht := size/4, dwid := size/8;
- local wsize := dwid;
- :poly(4,size);
- :turn(90); :go(dht); :turn(-90);
- :rect(dht,dwid); // door
- :move(3*dht);
- :poly(4,wsize); // window
- :turn(90); :move(size/2); :turn(-90);
- :poly(4,wsize); // window
- end
- ----------
- rect
- func(side1,side2)
- begin
- local i;
- for i:=1 to 2
- do begin
- :go(side1); :turn(90);
- :go(side2); :turn(90);
- end;
- end
- ----------
- BYE!
-